package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.corona.Game;
import com.corona.game.util.SpriteProxy;
import com.corona.game.util.TextureCache;

/* compiled from: Battle.java */
/* access modifiers changed from: package-private */
/* loaded from: pokewilds.jar:com/pkmngen/game/DrawBattle.class */
public class DrawBattle extends Action {
    SpriteProxy bgSprite2;
    SpriteProxy oppPokemonOver;
    public DrawFriendlyHealth drawFriendlyHealthActionGen1;
    public DrawFriendlyHealthGen2 drawFriendlyHealthAction;
    public DrawEnemyHealth drawEnemyHealthActionGen1;
    public DrawEnemyHealthGen2 drawEnemyHealthAction;
    public Action drawFriendlyPokemonAction;
    public static boolean shouldDrawOppPokemon = true;
    public static boolean shouldDrawOwnPokemon = true;
    public static boolean hideOppPokemon = false;
    public static boolean hideOwnPokemon = false;
    public static int prevFriendlyAttackIndex = -1;
    public static int prevEnemyAttackIndex = -1;
    boolean doneNightOverlay = false;
    public Action.Layer layer = Action.Layer.gui_130;
    public DrawNightOverlay drawNightOverlay = null;
    SpriteProxy bgSprite = new SpriteProxy(Color.WHITE, TextureCache.get(Gdx.files.internal("battle/battle_bg3.png")), 0, 0, 176, 160);

    public DrawBattle(Game game) {
        super(new Object[0]);
        game.battle.drawAction = this;
        this.bgSprite.setPosition(-8.0f, -8.0f);
        Texture text = TextureCache.get(Gdx.files.internal("battle/intro_frame6.png"));
        this.bgSprite2 = new SpriteProxy(text, 0, 0, 160, 144);
        this.oppPokemonOver = new SpriteProxy(text, 0, 0, 56, 40);
        this.oppPokemonOver.setX(96.0f);
        this.oppPokemonOver.setY(48.0f);
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    public void cleanup(Game game) {
        game.player.dontDrawMapDuringBattle = false;
        game.actionStack.remove(this);
        game.actionStack.remove(this.drawNightOverlay);
        if (game.battle.drawAction instanceof RegigigasBattle.Draw) {
            ((RegigigasBattle.Draw) game.battle.drawAction).soundEffect.stop();
            ((RegigigasBattle.Draw) game.battle.drawAction).soundEffect.dispose();
        }
        game.battle.drawAction = null;
    }

    @Override // com.corona.game.Action
    public void firstStep(Game game) {
        prevFriendlyAttackIndex = -1;
        prevEnemyAttackIndex = -1;
        game.player.dontDrawMapDuringBattle = true;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (!this.doneNightOverlay && game.map.timeOfDay.equals("night") && (game.battle.oppPokemon == null || !SpecialMewtwo1.class.isInstance(game.battle.oppPokemon))) {
            this.drawNightOverlay = new DrawNightOverlay();
            game.insertAction(this.drawNightOverlay);
            this.doneNightOverlay = true;
        }
        this.bgSprite.draw(game.uiBatch);
        if (shouldDrawOppPokemon && !hideOppPokemon) {
            game.battle.oppPokemon.sprite.draw(game.uiBatch);
            this.oppPokemonOver.draw(game.uiBatch);
        }
        game.player.battleSprite.draw(game.uiBatch);
        for (int i = -1; i < 2; i++) {
            for (int j = -1; j < 2; j++) {
                if (i != 0 || j != 0) {
                    game.uiBatch.draw(this.bgSprite2, (float) (160 * i), (float) (144 * j));
                }
            }
        }
    }

    /* compiled from: Battle.java */
    /* access modifiers changed from: package-private */
    /* loaded from: pokewilds.jar:com/pkmngen/game/DrawBattle$DrawNightOverlay.class */
    public class DrawNightOverlay extends Action {
        public Action.Layer layer = Action.Layer.gui_0;
        Sprite bgSprite = new Sprite(TextureCache.get(Gdx.files.internal("battle/intro_frame1.png")), 0, 0, 160, 144);

        /* JADX INFO: 'super' call moved to the top of the method (can break code semantics) */
        public DrawNightOverlay() {
            super(new Object[0]);
            DrawBattle.this = this$0;
        }

        @Override // com.corona.game.Action
        public String getCamera() {
            return "gui";
        }

        @Override // com.corona.game.Action
        public Action.Layer getLayer() {
            return this.layer;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            if (game.map.timeOfDay.equals("day") || game.map.currRoute.isDungeon) {
                game.actionStack.remove(this);
                return;
            }
            for (int i = -1; i < 2; i++) {
                for (int j = -1; j < 2; j++) {
                    game.uiBatch.draw(this.bgSprite, (float) (160 * i), (float) (144 * j));
                }
            }
        }
    }
}
